package com.project.bean;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelIgnore;
import cn.afterturn.easypoi.excel.annotation.ExcelTarget;

import java.io.Serializable;
import java.time.LocalDate;
import java.util.Arrays;
import java.util.List;

@ExcelTarget("users")
public class UserBean implements Serializable {
    @Excel(name = "编号",orderNum = "1")
    private Integer id;
    @Excel(name = "姓名",orderNum = "2")
    private String name;
    @Excel(name = "工资",orderNum = "4")
    private Integer money;
    @Excel(name = "生日",orderNum = "3",width = 20.0)
    private LocalDate birthday;
    @ExcelIgnore
    private List<String> habby;
    @Excel(name = "爱好",orderNum = "5",width = 20.0)
    private String habbyStr;

    public UserBean(Integer id, String name, Integer money,
                    LocalDate birthday,String... hstr) {
        this.id = id;
        this.name = name;
        this.money = money;
        this.birthday = birthday;
        habby = Arrays.asList(hstr);
    }

    public UserBean() {
    }

    public List<String> getHabby() {
        return habby;
    }

    public void setHabby(List<String> habby) {
        this.habby = habby;
    }

    public String getHabbyStr() {
        String str = Arrays.toString(this.habby.toArray(new String[0]));
        str = str.replaceAll("([\\[\\]])+","");
        return str;
    }

    public void setHabbyStr(String habbyStr) {
        this.habbyStr = habbyStr;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getMoney() {
        return money;
    }

    public void setMoney(Integer money) {
        this.money = money;
    }

    public LocalDate getBirthday() {
        return birthday;
    }

    public void setBirthday(LocalDate birthday) {
        this.birthday = birthday;
    }

    @Override
    public String toString() {
        return "UserBean{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", money=" + money +
                ", birthday=" + birthday +
                ", habby=" + habby +
                ", habbyStr='" + habbyStr + '\'' +
                "}\n";
    }
}
